package com.zzjson.controller;

import com.zzjson.domain.Hotel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2019 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : com.zzjson</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2019年04月09日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
//@RestController
//@RequestMapping("/dd")
public class TestController {
    @Autowired
    private MongoTemplate mongoTemplate;

    @RequestMapping
    public String test(String ss4) {
        return ss4;
    }

    @RequestMapping("/mongo")
    public List<Hotel> findHotel(String name) {
        Criteria criteria = Criteria.where("dd").is("dd");
        Query query = new Query(criteria);
        List<Hotel> list = mongoTemplate.find(query, Hotel.class);
        return list;
    }

    @RequestMapping("save")
    public void save() {
        Hotel hotel = new Hotel();
        hotel.setHotelName("dd");
        mongoTemplate.save(hotel);
    }

}